<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>set结构</title>
</head>

<body>
    <script>
        const set = new Set()
        console.log(set.size);
        const set1 = new Set(['a', 'b'])
        console.log(set1.size);
        const set2 = new Set(['a', 'b', 'c', 'b', ])
        console.log(set2.size);

        //遍历取值
        set2.forEach(item => {
            console.log(item);
        })

        // 方法  可以进行链式操作
        // 1.add 添加值
        set.add('12')
        console.log(set.size);
        // 2.delete 删除值
        set1.delete('a')
        console.log(set1.size);
        // 3.has 查找值  返回布尔值
        console.log(set2.has('b'));
        // 4. clear 清空值
        set2.clear()
        console.log(set2.size);
    </script>
</body>

</html>